Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor the CookieJar interface for more implementation independence #56

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Leptopoda
Copy link

@Leptopoda Leptopoda commented Apr 13, 2024

Hi there and thank you for this package.
I hereby suggest a few changes to the interface of the CookieJar class. We wanted to implement a custom cookie storage backend in sql and ended up writing a custom CookieJar instead of just using a custom Storage.

We did observe that the api is quite biased towards the DefaultCookieJar implementation and not really considering other implementations.
We decided to go with:

  • an api that can handle both synchronous and asynchronous implementations by using FutureOr
  • an api that is implementation independent by not requiring the variable ignoreExpires that not every cookie store needs (we strive for RFC compliance so we do not need the option to ignore the expiration).
  • replacing the delete with a deleteWhere function so users of the api can decide with higher precision what cookies they want to be removed.
  • implementing an endSession function to remove non persistent cookies as described in the RFC

This is just a proposal and we are open to talk about changes. We hope you consider these changes even if they are breaking. Obviously there are less breaking ways to achieve this like keeping around the delete function and just deprecating it for now.
We are also open to upstream the rest of our RFC compliance focused code if you are open and interested in further changes.

@Leptopoda Leptopoda changed the title refactor!: user FutureOr on the interface to allow for synchronous im… refactor the CookieJar interface for more implementation independence Apr 13, 2024
Copy link
Member

@AlexV525 AlexV525 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Leptopoda Thanks for your contribution, and of course they are welcomed!

Regarding the breaking part, a detailed migration guide would be helpful for the process. Also you may want to check the compatibility with dio_cookie_manager and other downstream packages to learn their cases.

About RFCs, it would be great if you could ref them as comments directly in the code, so we can always follow them.

lib/src/jar/persist.dart Outdated Show resolved Hide resolved
lib/src/jar/persist.dart Outdated Show resolved Hide resolved
lib/src/jar/persist.dart Show resolved Hide resolved
@Leptopoda Leptopoda force-pushed the refactor/better_extensibility branch from 93416bc to b952da4 Compare April 19, 2024 07:56
@Leptopoda Leptopoda requested a review from AlexV525 April 19, 2024 07:57
@AlexV525
Copy link
Member

AlexV525 commented Jun 9, 2024

Sorry it has been a while since the last review. Could you fix all the tests?

@provokateurin
Copy link
Contributor

The linting is failing, not the tests

@AlexV525
Copy link
Member

Yeah and the lints too

@Leptopoda Leptopoda force-pushed the refactor/better_extensibility branch from b952da4 to 08b66c4 Compare July 8, 2024 20:48
@Leptopoda
Copy link
Author

Leptopoda commented Jul 8, 2024

Sorry for my inactivity. The CI should be passing now.
Our own implementation is finished and already deployed to our users. If you are open for bigger refactors and enhancing the code readability of the current code I'll happily contribute it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants